home *** CD-ROM | disk | FTP | other *** search
/ SGI Freeware 2002 November / SGI Freeware 2002 November - Disc 3.iso / dist / fw_qt3.idb / usr / freeware / Qt / examples / action / toggleaction / toggleaction.cpp.z / toggleaction.cpp
C/C++ Source or Header  |  2002-04-08  |  876b  |  31 lines

  1. #include <qapplication.h>
  2. #include <qmainwindow.h>
  3. #include <qtoolbar.h>
  4. #include <qaction.h>
  5.  
  6. #include "labelonoff.xpm"
  7.  
  8. int main( int argc, char **argv )
  9. {
  10.     QApplication app( argc, argv );
  11.     QMainWindow * window = new QMainWindow;
  12.     window->setCaption("Qt Example - Toggleaction");
  13.     QToolBar * toolbar = new QToolBar( window );
  14.  
  15.     QAction * labelonoffaction = new QAction( window, "labelonoff", TRUE );  
  16.  
  17.     labelonoffaction->setText( "labels on/off" ); 
  18.     labelonoffaction->setAccel( Qt::ALT+Qt::Key_L );
  19.     labelonoffaction->setIconSet( (QPixmap) labelonoff_xpm );                                 
  20.  
  21.     QObject::connect( labelonoffaction, SIGNAL( toggled( bool ) ), 
  22.                       window, SLOT( setUsesTextLabel( bool ) ) );
  23.  
  24.     labelonoffaction->addTo( toolbar ); 
  25.  
  26.     app.setMainWidget( window );
  27.     window->show();
  28.     return app.exec();
  29. }
  30.  
  31.